//
//  HomeStormFromModel_Two.m
//  Gxj
//
//  Created by 刘伟 on 2017/9/28.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "HomeStormFromModel_Two.h"

NSString *const kStormModelThinkid     = @"thinkid";
NSString *const kStormModelUserid      = @"userid";
NSString *const kStormModelInfo        = @"info";
NSString *const kStormModelViewnum     = @"viewnum";
NSString *const kStormModelCreate_date = @"create_date";
NSString *const kStormModelIndustryid  = @"industryid";
NSString *const kStormModelHead_img    = @"head_img";
NSString *const kStormModelLevel       = @"level";
NSString *const kStormModelNickname    = @"nickname";
NSString *const kStormModelImgsrc      = @"imgsrc";
NSString *const kStormModelBestuser    = @"bestuser";
NSString *const kStormModelFollow      = @"follow";
NSString *const kStormModelTitle       = @"title";

@implementation HomeStormFromModel_Two

@synthesize thinkid     = _thinkid;
@synthesize userid      = _userid;
@synthesize info        = _info;
@synthesize viewnum     = _viewnum;
@synthesize create_date = _create_date;
@synthesize industryid  = _industryid;
@synthesize head_img    = _head_img;
@synthesize level       = _level;
@synthesize nickname    = _nickname;
@synthesize imgsrc      = _imgsrc;
@synthesize bestuser    = _bestuser;
@synthesize follow      = _follow;
@synthesize title       = _title;

+ (instancetype)modelObjectWithDictionary:(NSDictionary *)dict
{
    return [[self alloc] initWithDictionary:dict];
}

// 初始化
- (instancetype)initWithDictionary:(NSDictionary *)dict
{
    self = [super init];
    if (self && [dict isKindOfClass:[NSDictionary class]])
    {
        _thinkid     = [self checkNilObjectForKey:kStormModelThinkid        fromDictionary:dict];
        _userid      = [self checkNilObjectForKey:kStormModelUserid         fromDictionary:dict];
        _info        = [self checkNilObjectForKey:kStormModelInfo           fromDictionary:dict];
        _viewnum     = [self checkNilObjectForKey:kStormModelViewnum        fromDictionary:dict];
        _create_date = [self checkNilObjectForKey:kStormModelCreate_date    fromDictionary:dict];
        _industryid  = [self checkNilObjectForKey:kStormModelIndustryid     fromDictionary:dict];
        _head_img    = [self checkNilObjectForKey:kStormModelHead_img       fromDictionary:dict];
        _level       = [self checkNilObjectForKey:kStormModelLevel          fromDictionary:dict];
        _nickname    = [self checkNilObjectForKey:kStormModelNickname       fromDictionary:dict];
        _imgsrc      = [self checkNilObjectForKey:kStormModelImgsrc         fromDictionary:dict];
        _bestuser    = [self checkNilObjectForKey:kStormModelBestuser       fromDictionary:dict];
        _follow      = [self checkNilObjectForKey:kStormModelFollow         fromDictionary:dict];
        _title       = [self checkNilObjectForKey:kStormModelTitle          fromDictionary:dict];
    }
    return self;
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
    [mutableDict setValue:_thinkid          forKey:kStormModelThinkid];
    [mutableDict setValue:_userid           forKey:kStormModelUserid];
    [mutableDict setValue:_info             forKey:kStormModelInfo];
    [mutableDict setValue:_viewnum          forKey:kStormModelViewnum];
    [mutableDict setValue:_create_date      forKey:kStormModelCreate_date];
    [mutableDict setValue:_industryid       forKey:kStormModelIndustryid];
    [mutableDict setValue:_head_img         forKey:kStormModelHead_img];
    [mutableDict setValue:_level            forKey:kStormModelLevel];
    [mutableDict setValue:_nickname         forKey:kStormModelNickname];
    [mutableDict setValue:_imgsrc           forKey:kStormModelImgsrc];
    [mutableDict setValue:_bestuser         forKey:kStormModelBestuser];
    [mutableDict setValue:_follow           forKey:kStormModelFollow];
    [mutableDict setValue:_title            forKey:kStormModelTitle];
    
    return [NSDictionary dictionaryWithDictionary:mutableDict];
}

- (id)checkNilObjectForKey:(id)key fromDictionary:(NSDictionary *)dict
{
    id object = [dict objectForKey:key];
    return [object isKindOfClass:[NSNull class]] ? nil : object;
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"%@",[self dictionaryRepresentation]];
}

@end
